<?php

namespace system\Model;

use informatica\Model\Usuarios;

class Perfil extends Usuarios {

    public $_table = "usuarios";
    public $_view = "vw_usuarios";
    protected $controller_id = 182;

    public function loadbyid_view($id){
        $rs = $this->select()->from($this->_view)->where("id=:id")->execPrepQuery(["id"=>$id]);
        return $rs[0];
    }

    public function validaSenha($senha){
        $total = $this->countAll()->from()->where("senha = :s")->execPrepCount(["s"=>$senha]);
        return ($total > 0) ? true : false;
    }

    public function updateSenha($senha){
        $data["action_type"] = "update";
        $data["senha"] = $senha;
        $where = "id = " . $_SESSION["authe"]["USER"]["USUARIO_ID"];
        return $this->AutoExecute($data, $this->_table, $where);
    }
	
}